#pragma once
#include "afxwin.h"
#include "afxcmn.h"

#include "ListCtrlEx.h"
#include"ListBoxEx.h"

class CVaxSIPUserAgent;

class CChatDlg : public CPropertyPage
{
	DECLARE_DYNAMIC(CChatDlg)

public:
	CChatDlg(CVaxSIPUserAgent*);
	virtual ~CChatDlg();

	enum { IDD = IDD_CHAT_DLG };

protected:
	virtual void DoDataExchange(CDataExchange* pDX);    // DDX/DDV support

	DECLARE_MESSAGE_MAP()

public:
	virtual BOOL OnInitDialog();
	virtual BOOL OnApply();

public:
	void OnVaxInitialize();
	void OnVaxUnInitialize();

private:
	CVaxSIPUserAgent* m_pVaxSIPUserAgent;

	CFont m_objFont;

public:
	CComboBox m_ctrlComboMyChatStatus;

private:
	void UpdateStatusCombo();
	void AddToChatLog(LPCTSTR sChatLog);

	CString GetStatusText(int nStatusId);

	void IsTyping();
	void UpdateChatMessageBox(LPCTSTR sChatMessage);

private:
	BOOL m_bTyping;

/////////////////////////////////////////////////////////////////////////////////////////////
/////////////////////////////////////////////////////////////////////////////////////////////

public:
	void OnChatContactStatus(CString sUserName, int nStatusId);
    void OnChatSendMsgTextSuccess(LPCTSTR sUserName, LPCTSTR sMsgText, int nUserValue32bit);
    void OnChatSendMsgTextFail(LPCTSTR sUserName, int nStatusCode, LPCTSTR sReasonPhrase, LPCTSTR sMsgText, int nUserValue32bit);
    void OnChatSendMsgTypingSuccess(LPCTSTR sUserName, int nUserValue32bit);
    void OnChatSendMsgTypingFail(LPCTSTR sUserName, int nStatusCode, LPCTSTR sReasonPhrase, int nUserValue32bit);
    void OnChatRecvMsgText(CString sUserName, CString sMsgText);
    void OnChatRecvMsgTypingStart(CString sUserName);
    void OnChatRecvMsgTypingStop();

private:
	CListBoxEx m_ctrlListChatLog;
	CListBoxEx m_ctrlListChatMessage;

	CListCtrlEx m_ctrlCListChatContact;

	CString m_sLblChatStatus;
	CString m_sEditChatContact;
	CString m_sEditChatUserName;
	CString m_sEditSendChatMessage;

public:
	afx_msg void OnBtnClickedAddContact();
	afx_msg void OnBtnClickedRemoveContact();
	afx_msg void OnBtnClickedClearChat();
	afx_msg void OnBtnClickedSendMessage();
	afx_msg void OnBtnClickedClearLog();
	afx_msg void OnTimer(UINT_PTR nIDEvent);

	afx_msg void OnChangeEditMessage();
	afx_msg void ComboMyChatStatus_SelectedIndexChanged();
	afx_msg void OnLbnSelchangeListchatmsg();
};
